//
//  TimeTool.h
//  fastSign
//
//  Created by 朱潮 on 14-5-17.
//  Copyright (c) 2014年 zhuchao. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "KLSingleton.h"

#ifndef GET_TODAY_DATE
    #define GET_TODAY_DATE  [NSDate date]
#endif

@interface KLTimeTool : NSObject
KLDEC_SINGLETON(KLTimeTool);

// 当前时间戳
+ (NSTimeInterval)formatTimeSinceNow:(NSTimeInterval)timestamp;
//根据timestamp来获取日期
+ (NSString *)formatTime:(NSTimeInterval)timestamp formatWith:(NSString *)format;
//根据date来获取日期
+ (NSString *)formatDate:(NSDate *)date formatWith:(NSString *)format;
//根据timestamp偏差来获取日期
+ (NSString *)formatDateSinceNow:(NSTimeInterval)timestamp formatWith:(NSString *)format;
//获取时间差
+ (NSString *)getTimeDiffString:(NSTimeInterval)timestamp;
//获取时间差
+ (NSString *)getTimeDiffString:(NSTimeInterval)timestamp formatWith:(NSString *)format;
+ (NSString *)getTimeDiffStringForMgr:(NSTimeInterval)timestamp formatWith:(NSString *)format;

//格式化时间 e.p “从 2013-8-12 至 2013-8-18 "
+ (NSString *)getWeekKeyString:(NSTimeInterval)timestamp;
+ (NSString *)getFirstDayForWeekKeyString:(NSTimeInterval)timestamp;
//格式化时间 e.p 2013-08
+ (NSString *)getMonthKeyStringByOffset:(NSInteger)month;
+ (NSInteger)getTotalDayInMonth:(NSTimeInterval)timestamp;

//获取本星期的第一天的timestamp
+ (NSTimeInterval)getFirstDayOfWeek:(NSTimeInterval)timestamp;
//获取本月第一天的timestamp
+ (NSTimeInterval)getFirstDayOfMonth:(NSTimeInterval)timestamp;
//获取上月第一天的timestamp
+ (NSTimeInterval)getFirstDayOfLastMonth:(NSTimeInterval)timestamp;
//获取本季度第一天的timestamp
+ (NSTimeInterval)getFirstDayOfQuarter:(NSTimeInterval)timestamp;

//这个月
+ (NSUInteger)getSecond;
+ (NSUInteger)getMintue;
+ (NSUInteger)getHour;
+ (NSUInteger)getMonth;
+ (NSUInteger)getToday;
+ (NSUInteger)getYear;

+ (NSDate*)dateFromYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day hour:(NSInteger)hour minute:(NSInteger)minute second:(NSInteger)second;

+ (NSTimeInterval)timestampFromDateString:(NSString*)dateString formate:(NSString*)formate;

+ (NSString *)fixStringForDate:(NSDate *)date formatWith:(NSString *)format;

+(NSDate*) convertDateFromString:(NSString*)uiDate   formate:(NSString*)formate;
@end
